<template>

	<el-form ref="form" :model="form" label-width="80px">
	  <el-form-item label="buildArea">
	    <el-input v-model="form.buildArea"></el-input>
	  </el-form-item>
	  <el-form-item label="communityIntroduction">
	    <el-input v-model="form.communityIntroduction"></el-input>
	  </el-form-item>
	  
	  <el-form-item label="coverArea">
	    <el-input v-model="form.coverArea"></el-input>
	  </el-form-item>
	  <el-form-item label="id">
	    <el-input v-model="form.id"></el-input>
	  </el-form-item>
	  <el-form-item label="name">
	    <el-input v-model="form.name"></el-input>
	  </el-form-item>
	  <el-form-item label="ownersNumber">
	    <el-input v-model="form.ownersNumber"></el-input>
	  </el-form-item>
	  
	  <el-form-item>
	    <el-button type="primary" @click="update()">修改</el-button>
	    <el-button>取消</el-button>
	  </el-form-item>
	</el-form>
</template>

<script>
	
	import axios from "axios"
	
	export default {
	    data() {
	      return {
	        form: {
				buildArea:'',
				communityIntroduction:'',
				coverArea:'',
				id:'',
				imageUrl:'',
				name:'',
				ownersNumber:''
	         },
			rId:''
	      }
	    },
	    methods: {
	      onSubmit() {
	        console.log('submit!');
			axios.post('http://localhost:9080/v1/user/login',this.form).then(res=>{
				if(res.data.code==1){
					alert("OK")
					this.$router.push({path:'/index'})
					
				}else{
					alert("登陆失败")
				}
			})
	      },
		  //updateResidentialQuarters
		  update(){
			  axios.post('http://localhost:9071/residentialquarters/updateResidentialQuarters',this.form).then(res=>{
				  if(res.data.code==1){
					  alert("OK")
					  this.$router.push({path:'/residentialQuarters'})
				  }
			  })
		  }
	    },
		created() {
				  console.log("=======================")
		  console.log(this.$route.params.id)
		  this.rId = this.$route.params.id
		  //http://localhost:9071/residentialquarters/findResidentialQuartersById/1
		  axios.get('http://localhost:9071/residentialquarters/findResidentialQuartersById/'+this.rId).then(res=>{
			  console.log(res)
			  if(res.data.code==1){
				 this.form =  res.data.data;
				console.log(this.form)
				  
			  }
		  })
		  
		  
		}
		
	  }
	// 在目标组件中获取路由参数

	
</script>

<style>
</style>